#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vi: ts=4 expandtab
#
# Copyright (C) 2012 KT
#
# Author: Choonho Son <choonho.son@kt.com>
#

import subprocess
import os
import os.path
from cloudcfg.lib.cmd import Cmd

__version__="1.0"

class cmd_account(Cmd):
	def __init__(self, logger):
		Cmd.__init__(self,logger)

	def useradd(self, params):
		"""
		create user
		return key files path
		
		@params (dictionary)
		base-dir : base directory 
		home-dir : base-dir | user
		user  : user id
		@return : True/False
		"""
		p = params
		if os.path.exists(p['base-dir']) == False:
			os.makedirs(p['base-dir'])
			
		cmd = [ 'useradd', '-m', '-d', p['home-dir'], p['user']]
		self.run(cmd)


